package com.haidechizi.leetcode;

/**
 * @author: wangdejun
 * @create: 2020-04-22 12:29
 **/
public class _8_递归乘法 {

    public int multiply(int A, int B) {
        if (B <= 1) {
            return A;
        }
        int temp = A;
        A = A + A;
        if (A < 0) {
            return Integer.MAX_VALUE;
        }
        if (B % 2 == 1) {
            return multiply(A, B / 2) + temp;
        }
        return multiply(A, B / 2);
    }

    public static void main(String[] args) {
        System.out.println(new _8_递归乘法().multiply(1, 10));
    }


}
